class Solution {
public:
    int lengthOfLastWord(string s) {
        int end = s.size() - 1, len = 0;
        while(s[end] == ' ')
        {
            --end;
        }
        std::cout << s[end] << std::endl;
        while(end >= 0)
        {
            if(s[end] == ' ')
            {
                break;
            }
            ++len;
            --end;
        }
        return len;
    }
};